//
// Created by voyagerhui on 2022/3/18.
//

#ifndef CODECRAFT_2021_READ_WRITE_H
#define CODECRAFT_2021_READ_WRITE_H
#include "parameter.h"

class ReadWriteClass{
public:
    char *demand_csv = "C:\\Users\\PC\\Desktop\\huaweicodecraft2022\\data\\demand.csv";
    char *site_bandwidth_csv = "C:\\Users\\PC\\Desktop\\huaweicodecraft2022\\data\\site_bandwidth.csv";
    char *qos_csv = "C:\\Users\\PC\\Desktop\\huaweicodecraft2022\\data\\qos.csv";
    char *config_ini = "C:\\Users\\PC\\Desktop\\huaweicodecraft2022\\data\\config.ini";
    char *output_file = "C:\\Users\\PC\\Desktop\\huaweicodecraft2022\\data\\solution.txt";

//    char *demand_csv = "/data/demand.csv";
//    char *site_bandwidth_csv = "/data/site_bandwidth.csv";
//    char *qos_csv = "/data/qos.csv";
//    char *config_ini = "/data/config.ini";
//    char *output_file = "/output/solution.txt";

    enum format{
        qos_row_1 = 1,
        qos_row_2 = 2,
        demand_row_1 = 3,
        demand_row_2 = 4,
        site_bandwidth_row_2 = 5,
        config_row_2 = 6
    };
    vector<vector<int>> qos;
    map<string, vector<int>> demand;
    map<string, int> site_bandwidth;
    int qos_constraint;

    vector<string> T_name;  // 时刻序列
    vector<string> client_name;  // 客户节点名称
    vector<string> server_name;  // 边缘节点名称
    vector<string> client_name_in_demand; // demand.csv文件中客户节点顺序
    map<string, int> client_name2idx;  // 客户名称转qos列索引
    map<string, int> server_name2idx;  // 边缘节点名称转qos行索引

    void parse_row(string s, int format);  // 解析文件格式
    void read_data();       // 读取文件数据
    void print_data();      // 打印读入的数据
    void write_answer(vector<string>& ans);      // 打印读入的数据
};

#endif //CODECRAFT_2021_READ_WRITE_H
